import {Button,Modal,message,Spin} from 'antd' 
const confirm = Modal.confirm;
import {WeaErrorPage,WeaTools,WeaAlertPage,WeaTab} from "ecCom"
import {WeaTableNew,WeaSwitch} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
import { inject, observer } from 'mobx-react';
import {toJS} from "mobx"
import {Condition} from "../list/customCondition"
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;

@observer
class ModifyRecord extends React.Component {
    constructor(props) {
		super(props);
        this.state={
        }
    }
    componentDidMount() {
    	const {contentStore,location:{query}} = this.props;
        contentStore.getViewLogList(query);
        contentStore.getViewLogCondition();
        contentStore.getViewLogRightMenu({selectType:'loginfo',customerId:query.customerId});
    }
    componentWillUnmount(){
        // const {contentStore} = this.props;
        // contentStore.clearStatus();
    }
    render(){
        const {contentStore} = this.props;
        const {modifyAuth:{verified,hasRight},modifyTableStore,customerId,showSearchAd,viewlogForm,viewlogCondition} = contentStore;
        if (verified && !hasRight) {
            return (<WeaAlertPage >
                    <div style={{color : '#000'}}>
                        {getLabel(2012,"对不起，您暂时没有权限！")}
                    </div>
                </WeaAlertPage>
            )
        }
        if (verified && hasRight) {
            return (
                <div style={{height:"100%"}}>
                    <WeaTab
                        buttonsAd={this.getAdButtons()}
                        searchType={['advanced']}
                        setShowSearchAd={bool=>{contentStore.setShowSearchAd(bool)}}
                        hideSearchAd={()=> contentStore.setShowSearchAd(false)}
                        searchsAd={
                            <div><Condition  condition={viewlogCondition} form ={viewlogForm} onEnterSearch={this.onEnterSearch}/></div>
                        }
                        showSearchAd={showSearchAd}
                    />
                    <WeaTable 
                        comsWeaTableStore={modifyTableStore}
                        hasOrder={true}
                        needScroll={true}
                    />
                   
                </div>
            )
        }
        return <div></div>
    }
    getAdButtons = () => {
        const {contentStore} = this.props;
        const {setShowSearchAd,getViewLogList,viewlogForm} = contentStore;
        return [
            (<Button type="primary" onClick={()=>{getViewLogList();setShowSearchAd(false);}}>{getLabel(197,"搜索")}</Button>),
            (<Button type="ghost" onClick={()=>{viewlogForm.resetConditionValue();}}>{getLabel(2022,"重置")}</Button>),
            (<Button type="ghost" onClick={()=>{setShowSearchAd(false)}}>{getLabel(201,"取消")}</Button>)
        ];
    }
    onEnterSearch=()=>{
        const {contentStore} = this.props;
        contentStore.getViewLogList();
        contentStore.setShowSearchAd(false);
    }

}

export default WeaTools.tryCatch(React,
    props => <WeaErrorPage msg={ props.error ? props.error : getLabel(129417,'服务器运行出错，请联系系统管理员！')} />,
    {error: ""}
)(ModifyRecord);